package org.util;

import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

/**
 * @Auther: qingle
 * @Date: 2024/9/8-7:02
 * @Description: 日志工具类
 * @version: 1.0
 */
public class LogUtils {

	public static void info(String msg, Object... args) {
		print(msg, "-INFO-", args);
	}

	public static void error(String msg, Object... args) {
		print(msg, "-ERROR-", args);
	}

	public static void warn(String msg, Object... args) {
		print(msg, "-WARN-", args);
	}

	public static void debug(String msg, Object... args) {
		print(msg, "-DEBUG-", args);
	}

	private static void print(String msg) {
		print(msg, null);
	}
	private static void print(String msg, String level, Object... args) {
		if (args != null && args.length > 0) {
			msg = String.format(msg.replace("{}", "%s"), args);
		}
		String name = Thread.currentThread().getName();
		System.out.println(LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")) + " " + level + " " + name + " " + msg);
	}
}
